<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" isErrorPage="true"%>
<%@include file="/WEB-INF/common/taglib.jsp"%>
<%@page import="org.slf4j.Logger" %>
<%@page import="org.slf4j.LoggerFactory" %>
<%@page import="java.io.PrintWriter" %>
<%@page import="java.io.StringWriter" %>

<% 
	Logger logger = LoggerFactory.getLogger("<<<500error page>>>");
	Throwable ex=exception != null ? exception : (Throwable)request.getAttribute("javax.servlet.error.exception");
	com.pricl.frame.core.R result = com.pricl.frame.core.R.exception(ex);
	/* ex.printStackTrace(); */
	
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);
	ex.printStackTrace(pw);
	logger.error(sw.toString());
	
	if(ex != null && (ex instanceof com.pricl.frame.core.E)){
		//System.out.println(ex.getMessage());
		if("post".equalsIgnoreCase(request.getMethod())) {
			response.setContentType("application/json;charset=UTF-8");
			response.setStatus(200);
			//System.out.println(result.msg);
			out.print("{code:'"+result.code+"',msg:'"+ex.getMessage()+"'}");
			return;
		}
	}
	//TODO
	if("post".equalsIgnoreCase(request.getMethod())) {
		response.setContentType("application/json;charset=UTF-8");
		response.setStatus(200);
		//System.out.println(result.msg);
		out.print("{code:'"+result.code+"',msg:'系统异常!'}");
		return;
	}
%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<title>500</title>
	</head>
	<body>
		500错误<br> 
		错误代码:<%=result.code %><br>
		错误信息:<%=result.msg %>
	</body>
</html>